import Global from "@/src/lib/global"
import { View, Image,Text } from "@tarojs/components"
import "./desc-row.scss"

interface DescRowProps {
    className?: string,
    title: string,
    titleColor?: string,
    desc?: string,
    showArrow?: boolean,
    activity?: any,
    onClick?: () => void
}

const DescRow = (props: DescRowProps) => {

    let arrowEl
    if (props.showArrow == true) {
        arrowEl = <Image className="arrow" src={Global.loadImage("icon_arrow_right@3x.png")} />
    }

    return (
        <View className={["desc-row", props.className].join(" ")} onClick={props.onClick}>
            <View>
                <View className="desc-row-title" style={{ color: props.titleColor }}>{props.title}</View>

                {
                    props.title !== '领券' && props.title !== '促销' ? (
                    <View className="desc-row-desc" >{props.desc}</View>
                    ) :props.title === '促销'?(<View className="cuxList" >
                        <View className="cux dis">{props.activity.activity.tag}</View>
                        <View className="texts">
                            {
                                props.activity.activity.mansonglist.map((item,index)=>{
                                    return (<Text>{item.tip}{
                                        props.activity.activity.mansonglist.length-1==index?null:<Text>，</Text>
                                    }</Text>)
                                })
                            }
                        </View>
                        <View className="rigImg"><Image className="arrow" src={Global.loadImage("icon_arrow_right@3x.png")} /></View>
                    </View>):
                    
                    (

                        props.activity.couponlist.map(item=>{
                            return (
                                <View className="desc">{item}</View>
                            )
                        }) 
                    )
                }
            </View>
            {arrowEl}
        </View>
    )
}

export default DescRow